package com.example.Lezedata.util;

import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.view.View;
import android.widget.Button;

import androidx.annotation.RequiresApi;

import org.jetbrains.annotations.NotNull;

public class GBViewUtil {
    @RequiresApi(api = Build.VERSION_CODES.O)
    public static void addBorderToView(@NotNull View view , Integer borderWidth , int borderColor){

//        <item android:width="335dp" android:height="50dp">
//  <shape android:shape="rectangle">
//    <solid android:color="#ffffffff" />
//    <stroke android:width="1dp" android:color="#ff2cc6f3" />
//    <corners android:topLeftRadius="25dp" android:topRightRadius="25dp" android:bottomLeftRadius="25dp" android:bottomRightRadius="25dp" />
//  </shape>
//</item>

        GradientDrawable drawable = new GradientDrawable();
        drawable.setShape(GradientDrawable.RECTANGLE); // 画框
        drawable.setStroke(borderWidth, Color.RED); // 边框粗细及颜色
        drawable.setCornerRadius(view.getHeight()/2);
//        drawable.setColor(borderColor); // 边框内部颜色
        view.setBackground(drawable);
    }
}
